package com.example.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.example.demo.pojo.Department;
import com.example.demo.pojo.Employee;
import com.example.demo.service.EmployeeService;

import javax.servlet.http.HttpSession;
import java.util.Collection;

@Controller
public class EmployeeController {

	/*
	 * @Autowired private EmployeeService employeeService;
	 * 
	 * // 查找列表
	 * 
	 * @GetMapping("/emps") public String list(Model model) { //
	 * employeeService.findAll(); return "emp/list"; }
	 * 
	 * 
	 * // 添加员工的界面 界面跳转到添加界面
	 * 
	 * @GetMapping("/emp") public String toAddPage(Model model) { // 查出所有部门信息
	 * Collection<Department> departments = departmentDao.getDepartments();
	 * 
	 * model.addAttribute("departments", departments); return "emp/add"; }
	 * 
	 * // 添加员工 post表单的形式进行提交
	 * 
	 * @PostMapping("/emp") public String addEmp(Employee employee) { // 后台调试输出
	 * System.out.println(employee); employeeDao.save(employee);// 调用底层业务方法保存
	 * System.out.println(employee);// 控制台的输出打印 return "redirect:/emps";
	 * 
	 * 视图解析器中有这两个规则 forword:转发 redirect:重定向直接找
	 * 
	 * }
	 * 
	 * // 跳转员工修改的页面
	 * 
	 * @GetMapping("/emp/{id}") public String toUpdatePage(@PathVariable("id")
	 * Integer id, Model model) { Employee employee =
	 * employeeDao.getEmployeeById(id); // 查出所有部门信息 Collection<Department>
	 * departments = departmentDao.getDepartments();
	 * 
	 * model.addAttribute("departments", departments);
	 * model.addAttribute("employee", employee); return "emp/update"; }
	 * 
	 * // 修改员工信息
	 * 
	 * @RequestMapping(value = "/updateEmp", method = RequestMethod.POST) public
	 * String updateEmp(Employee employee) { employeeDao.save(employee); return
	 * "redirect:/emps"; }
	 * 
	 * // 删除员工信息
	 * 
	 * @GetMapping("/deleEmp/{id}") public String deleEmp(@PathVariable("id")
	 * Integer id) { employeeDao.deleEmp(id); return "redirect:/emps"; }
	 */

}
